// TaskService.js - 任务相关API调用服务
import api from './index';

// 获取任务详情
export const getTaskDetail = (taskId) => {
  return api.get(`/tasks/${taskId}`);
};

// 更新任务
export const updateTask = (taskId, updateData) => {
  return api.put(`/tasks/${taskId}`, updateData);
};

// 获取任务子任务列表
export const getTaskSubtasks = (taskId) => {
  return api.get(`/tasks/${taskId}/subtasks`);
};

// 手动拆分任务
export const manualBreakdownTask = (taskId, tasksData) => {
  return api.post(`/tasks/${taskId}/manual-breakdown`, tasksData);
};

// 获取任务拆分版本列表
export const getTaskBreakdownVersions = (taskId) => {
  return api.get(`/tasks/${taskId}/breakdown-versions`);
};

// 获取特定拆分版本详情
export const getBreakdownVersionDetail = (versionId) => {
  return api.get(`/breakdown-versions/${versionId}`);
};

// 更新子任务
export const updateSubtask = (subtaskId, updateData) => {
  return api.put(`/subtasks/${subtaskId}`, updateData);
};

// 执行任务
export const executeTask = (subtaskId, executor = 'manual', result = '') => {
  return api.post(`/subtasks/${subtaskId}/execute`, { 
    executor, 
    result 
  });
};

// 更新任务拆分版本状态
export const updateBreakdownVersionStatus = (versionId, status) => {
  return api.put(`/breakdown-versions/${versionId}/status`, { status });
};

// 激活任务拆分版本
export const activateBreakdownVersion = (versionId) => {
  return api.put(`/breakdown-versions/${versionId}/activate`);
};

// 删除任务拆分版本
export const deleteBreakdownVersion = (versionId) => {
  return api.delete(`/breakdown-versions/${versionId}`);
};

// 其他任务相关的方法... 